package com.softer.wxzj.controller;

import com.github.pagehelper.PageInfo;
import com.softer.wxzj.common.aop.annotation.LogRecord;
import com.softer.wxzj.common.aop.enums.LogOperationType;
import com.softer.wxzj.common.aop.enums.LogOperationUnit;
import com.softer.wxzj.common.entity.CommonResult;
import com.softer.wxzj.common.entity.Page;
import com.softer.wxzj.entity.FileClassify;
import com.softer.wxzj.entity.FileClassifyDetail;
import com.softer.wxzj.service.FileClassifyDetailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author Gong Zhiyang
 * @date 2019/7/6
 */
@RestController
@RequestMapping("/fileClassify")
public class FileClassifyDetailController {
    @Autowired
    private FileClassifyDetailService fileClassifyDetailService;


    /**
     * 新增图档类型
     *
     * @param fileClassifyDetail 图档类型
     * @return 新增结果
     */
    @RequestMapping("/add")
    @LogRecord(description = "新增图档类型", operationUnit = LogOperationUnit.FILE_CLASSIFY_DETAIL, operationType = LogOperationType.INSERT)
    public CommonResult add(FileClassifyDetail fileClassifyDetail) {
        return fileClassifyDetailService.add(fileClassifyDetail);
    }

    /**
     * 获取业务分类下拉列表
     *
     * @param id 业务分类ID
     * @return 下拉列表
     */
    @RequestMapping("/getClassifyList")
    @LogRecord(description = "获取业务分类下拉列表", operationUnit = LogOperationUnit.FILE_CLASSIFY_DETAIL, operationType = LogOperationType.SELECT)
    public List<FileClassify> getClassifyList(String id) {
        return fileClassifyDetailService.getClassifyList(id);
    }

    /**
     * 查询图档详情
     *
     * @param id 图档ID
     * @return 详情
     */
    @RequestMapping("/getInfo")
    @LogRecord(description = "查询图档详情", operationUnit = LogOperationUnit.FILE_CLASSIFY_DETAIL, operationType = LogOperationType.SELECT)
    public FileClassifyDetail getInfo(String id) {
        return fileClassifyDetailService.getInfo(id);
    }

    /**
     * 修改图档
     *
     * @param fileClassifyDetail 图档实体
     * @return 修改结果
     */
    @RequestMapping("/update")
    @LogRecord(description = "修改图档", operationUnit = LogOperationUnit.FILE_CLASSIFY_DETAIL, operationType = LogOperationType.UPDATE)
    public CommonResult update(FileClassifyDetail fileClassifyDetail) {
        return fileClassifyDetailService.update(fileClassifyDetail);
    }

    /**
     * 获取业务分类的左侧三级菜单
     *
     * @return 三级菜单
     */
    @RequestMapping("/getFileClassifyList")
    @LogRecord(description = "获取业务分类的左侧三级菜单", operationUnit = LogOperationUnit.FILE_CLASSIFY_DETAIL, operationType = LogOperationType.SELECT)
    public FileClassify getFileClassifyList() {
        return fileClassifyDetailService.getFileClassifyList();
    }

    /**
     * 图档类型删除
     *
     * @param id ID
     * @return 删除结果
     */
    @RequestMapping("/delete")
    @LogRecord(description = "图档类型删除", operationUnit = LogOperationUnit.FILE_CLASSIFY_DETAIL, operationType = LogOperationType.DELETE)
    public CommonResult delete(String id) {
        return fileClassifyDetailService.delete(id);
    }

    /**
     * 图档列表查询
     *
     * @param page               分页实体
     * @param fileClassifyDetail 查询实体 必填字段id
     * @param fuzzy              模糊查询字段
     * @return 列表
     */
    @RequestMapping("/getList")
    @LogRecord(description = "图档列表查询", operationUnit = LogOperationUnit.FILE_CLASSIFY_DETAIL, operationType = LogOperationType.SELECT)
    public PageInfo<FileClassifyDetail> getList(Page page, FileClassifyDetail fileClassifyDetail, String fuzzy) {
        return fileClassifyDetailService.getList(page, fileClassifyDetail, fuzzy);
    }
}
